package com.zd.springcloud.order.controller;

import com.zd.springcloud.domain.Order;
<<<<<<< HEAD:springcloud-nacos-order/src/main/java/com/zd/springcloud/controller/OrderController.java
import com.zd.springcloud.service.OrderService;
import com.zd.springcloud.tccaction.OrderAction;
import io.seata.rm.tcc.api.BusinessActionContextUtil;
=======
import com.zd.springcloud.order.service.OrderService;

>>>>>>> a78a59f7e9652635f56bbcd587409434b2c8ef12:springcloud-nacos-order/src/main/java/com/zd/springcloud/order/controller/OrderController.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;

    @Autowired
    OrderAction orderAction;

    @PostMapping("/addOrder")
    public String addOrder(@RequestBody Order order){

        if(order.getId() == null){
            order.setId(System.nanoTime());

        }

        orderAction.addOrder(BusinessActionContextUtil.getContext(),order);
        return "success";
    }
}
